<?php
/*
 Plugin Name: Cirno Player
Plugin URI: https://www.cirnoworks.com
Description: 自动将页面中的所有mp3链接组合成播放列表并按顺序播放。提供充分的api以供和其他页面元素结合（比如说春菜等等）
Version: 0.2.0
Author: CirnoWorks.com
Author URI: https://www.cirnoworks.com
*/

function cirnoplayer_init()
{
	wp_enqueue_script('jplayer', WP_CONTENT_URL.'/plugins/cirno-player/jquery.jplayer.min.js', false, '2.2.0');
	wp_enqueue_script('cirnoplayer', WP_CONTENT_URL.'/plugins/cirno-player/cirnoplayer.js', false, '0.2.0');
}
function cirnoplayer_js(){?>
<link href="<?php echo WP_CONTENT_URL.'/plugins/cirno-player/cirnoplayer.css'?>" rel="stylesheet" type="text/css" />
<script type="text/javascript">
//<![CDATA[
jQuery(document).ready(function($){
	$.cirnoplayer({
			resourceUrl : "<?php echo WP_CONTENT_URL.'/plugins/cirno-player'?>",
			initialNodeMaker : function(uid, $node, $super){
				var ret = $super(uid, $node);
				if(ret){
					ret.url += "?saferef";
				}
				return ret;
			}
		});
	});
//]]>
</script>
<?php
}

function cirnoplayer_foot(){
	?>
<div id="cirnoplayer"></div>
<?php
}

add_action ('init', 'cirnoplayer_init');
add_filter('wp_head', 'cirnoplayer_js');
add_filter('wp_footer', 'cirnoplayer_foot');
?>